package com.second.controler;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.ibatis.session.SqlSession;

import com.second.dao.NewsDao;
import com.second.db.DbSqlSessionFactory;
import com.second.entity.News;


/**
 * Servlet implementation class DisNews
 */
@WebServlet("/dis.do")
public class DisNews extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DisNews() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		Map<String,Integer> map=new HashMap<String,Integer>();
		map.put("page", 1);
		map.put("code", 10);
		SqlSession ss=DbSqlSessionFactory.getSqlSession();
		NewsDao nd=ss.getMapper(NewsDao.class);
		List<News> list=nd.disNews(map);
		response.sendRedirect("/easyBuy/index.jsp");
		request.getSession().setAttribute("list", list);
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request,response);
	}

}
